Let go to the AWS management console, search for Cloudformation, click on Stacks, and checkout what we've deployed.
Under the Resources we can see:
- AWS::IAM::Role
- AWS::Lambda::Function
- AWS::CDK::Metadata
Click on the lambda function id to explore it. You'll be able to use the entire code, which starts with use strict and finishes with the sourcemap (because this code was transpiled from typescript).
Further down the page, you'll see Tags associated with this function (those were added automatically).
We currently don't have any Triggers so click on Test and Configure test event to test it manually. Choose Api Gateway AWS Proxy. Name the test then click Create.
Once you click Test again the lambda function will be called and you should see the console.log with "Hello, nothanii friends!" (or your own text).
Change the properties of a lambda function deployed with AWS CDK
Back in the aws console we can see that our lambda came preconfigured with memory size (128MB) and a timeout of 3 seconds. Let's change that!
Add the following lines to your stack document:
const helloLambda = new lambda.Function(this, "HelloLambda", {// to create a 10 second timeout (max is 15 minutes)timeout: cdk.Duration.seconds(10),// memory size of 256MBmemorySize: 256,});
Run cdk diff and cdk deploy then verify your changes in the aws console.